Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Text
Imports System.Windows.Forms
Imports C4F.DevKit.Contacts
Imports C4F.DevKit.Contacts.Controls

Namespace C4F.DevKit.Contacts.Samples.Win
	Public Partial Class ContactDetailDisplay
		Inherits Form
		#Region "Constructors"

		Public Sub New()
			Me.New(String.Empty)
		End Sub

		Public Sub New(ByVal contactID As String)
			InitializeComponent()

			Me.contactDetails1.ContactsService = Me.contactsService1
			If contactID = String.Empty Then
				Me.contactDetails1.Mode = ContactDetails.EditMode.Add
			Else
				Me.contactDetails1.Mode = ContactDetails.EditMode.Update
			End If

			If (Not DesignMode) Then
				Me.contactDetails1.SetContactID(contactID)
			End If

			AddHandler contactDetails1.ContactSaved, AddressOf contactDetails1_ContactSaved
			AddHandler contactDetails1.ContactSaveCanceled, AddressOf contactDetails1_ContactSaveCanceled
		End Sub

		#End Region ' Constructors

		#Region "Methods "

		#Region "Event Handlers"

		Private Sub contactDetails1_ContactSaveCanceled(ByVal sender As Object, ByVal e As EventArgs)
			OnContactSaveCanceled()
		End Sub

		Private Sub contactDetails1_ContactSaved(ByVal sender As Object, ByVal e As C4F.DevKit.Contacts.Controls.ContactSavedEventArgs)
			OnContactSaved()
		End Sub

		Private Sub ContactDetailDisplay_KeyUp(ByVal sender As Object, ByVal e As KeyEventArgs) Handles MyBase.KeyUp
			If e.KeyCode = Keys.Escape Then
				Close()
			End If
		End Sub

		#End Region ' Event Handlers    

		#Region "Private"

		Private Sub OnContactSaveCanceled()
			Close()
		End Sub

		Private Sub OnContactSaved()
			Close()
		End Sub

		#End Region ' Private

		#End Region ' Methods
	End Class
End Namespace